﻿using Domain.IRepository;
using Domain.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain.DomainService
{
    /// <summary>
    /// （商品）领域服务 将聚合根里面保存到数据库的操作分离出来  避免聚合根和仓储服务的循环依赖
    /// </summary>
    public class ProductMannage
    {
        public IProductRepository productRepository { get; set; }

        /// <summary>
        /// 业务规则；添加商品，商品名称不能重复
        /// </summary>
        /// <param name="productRepository"></param>
        /// <param name="productName"></param>
        public void InsertProduct(string productName)
        {
            Product product = new Product();
            product.ProductName = productName;
            bool bl = productRepository.GetProDuctName(productName);
            if (bl)
            {
                throw new Exception("名称不能重复");
            }
        }
    }
}
